High-precision semi-automatic image data labeling method, electronic apparatus, and storage medium

ABSTRACT

Disclosed are a high-precision semi-automatic image data labeling method, an electronic apparatus and a non-transitory computer-readable storage medium. The high-precision semi-automatic image data labeling method may include: displaying a to-be-labeled image, the to-be-labeled image comprising a selected area and an unselected area; acquiring a coordinate point of the unselected area and a first range value; executing a grabcut algorithm based on the coordinate point of the unselected area and the first range value acquired, and obtaining a binarized image divided by the grabcut algorithm; executing an edge tracking algorithm on the binarized image to acquire current edge coordinates; updating a local coordinate set based on the current edge coordinates acquired; updating the selected area of the to-be-labeled image based on the local coordinate set acquired.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a national stage filing under 35 U.S.C. § 371 of international application number PCT/CN2020/100349, filed on 6 Jul. 2020, which claims priority to Chinese patent application No. 2019111174067, filed on 15 Nov. 2019. The contents of these applications are incorporated herein by reference in their entirety.

TECHNICAL FIELD

The present disclosure relates to the technical field of computer image processing, and more particularly, to a high-precision semi-automatic image data labeling method, an electronic apparatus and a non-transitory computer-readable storage medium.

BACKGROUND

As an effective image segmentation algorithm to extract a foreground target from a complex background, a grabcut image cutting algorithm makes use of texture (color) information and boundary (contrast) information in the image, and achieves a better image segmentation effect. Inputting an image containing the target, and using the grabcut algorithm to cut the image can separate the foreground target from the background image, and output a binarized image with a white target and a black background.

An interactive method of the grabcut algorithm is realized by drawing a frame by a user. The user draws a frame to frame a foreground object and the foreground can be segmented after releasing a mouse. FIG. 5 is an effect graph of using the grabcut algorithm for image segmentation in the prior art. Generally, the grabcut algorithm may be used to segment the foreground, so as to obtain labeling data of a foreground image. However, when the grabcut algorithm is used to acquire the labeling data, only one frame may be drawn on the foreground image, which leads to a very large frame range when the grabcut algorithm is used on some foreground images with special contour shapes, thus resulting in a lot of background pixels in the frame, and decreasing the precision of the grabcut algorithm. Meanwhile, as a traditional grabcut algorithm lacks a function of correcting a target image obtained by image segmentation, that is, if an image segmentation effect in a data labeling process is not good, some background images may be included near an edge of the target image, and a method for correcting this situation is inefficient.

SUMMARY

The present disclosure aims at solving at least one of the technical problems in the prior art. Therefore, the present disclosure provides a high-precision semi-automatic image data labeling method, an electronic apparatus and a non-transitory computer-readable storage medium, which can execute a grabcut algorithm on a to-be-labeled image for multiple times to acquire an outline coordinate of a foreground image, and run correction when an erroneously selected area occurs in the foreground image acquired, thereby improving a labeling data precision of the image acquired.

In a first aspect, an embodiment of the present disclosure provides a high-precision semi-automatic image data labeling method, comprising the following steps of:

S100: displaying a to-be-labeled image, the to-be-labeled image comprising a selected area and an unselected area;

S200: acquiring a coordinate point of the unselected area and a first range value;

S300: executing a grabcut algorithm based on the coordinate point of the unselected area and the first range value acquired, and obtaining a binarized image segmented by the grabcut algorithm;

S400: executing an edge tracking algorithm on the binarized image to acquire current edge coordinates;

S500: updating a local coordinate set based on the current edge coordinates acquired;

S600: updating the selected area of the to-be-labeled image based on the local coordinate set acquired;

S700: determining whether an all-selected instruction is received; if yes, generating a whole coordinate set, and if not, returning to S200;

S800: determining whether an instruction indicating that an erroneously selected area occurs received; if yes, executing S900, and if not, executing S1000;

S900: acquiring a coordinate point of the erroneously selected area and a second range, and displaying a second square on the to-be-labeled image by the coordinate point of the erroneously selected area and the second range;

S910: determining whether a coordinate in the whole coordinate set exists in the second square; if not, returning to S900, and if yes, executing S920;

S920: acquiring a first coordinate point and a second coordinate point in the whole coordinate set that are duplicated with coordinates on edges of the second square, deleting the coordinate point in the whole coordinate set that are duplicated within a range of the second square, and adding the first coordinate point, the second coordinate point and a third coordinate point into the whole coordinate set, wherein the third coordinate point is a diagonal point among four diagonal points of the second square with a shortest path to a sum of the first and second coordinate points along the edges of the second square, and returning to S700; and

S1000: acquiring category information and saving the category information and the whole coordinate set as json files.

The high-precision semi-automatic image data labeling method according to the embodiment of the present disclosure at least has the following beneficial effects. In S200, the coordinate point of the unselected area and the first range value are acquired, a mouse is used to click on the unselected area to acquire a coordinate of the mouse as the coordinate point of the unselected area, and the coordinate point of the unselected area is used as a reference point to construct the first square according to the first range value input by the user, and this first square which is a frame-drawing operation in the grabcut algorithm. By selecting the coordinate point of the unselected area and the first range value for multiple times, the edge tracking algorithm may be executed after each instance of grabcut division to obtain the current edge coordinates, and the local coordinate set is updated by using the current edge coordinates. Finally, after the user confirms that the foreground area is fully selected, a key may be pressed on a keyboard to send out the all-selected instruction, then the local coordinate set in this case may be regarded as all the whole coordinate set, the user inputs the category information corresponding to the foreground image, and saves the category information and the whole coordinate set as json files for subsequent neural network training. Therefore, the high-precision semi-automatic image data labeling method provided by the embodiment can not only automatically segment by the grabcut algorithm, but also accept manual real-time intervention, thus improving the precision of image data labeling. Meanwhile, in S800, when the erroneously selected area occurs, the coordinate point of the erroneously selected area of the user and the second range are accepted, and the erroneously selected area is correspondingly deleted, thus providing a correction function, and thereby further improving the precision of image labeling.

In a specific embodiment of the present disclosure, the first range value is used for constructing a first square, and acquiring the first range value comprises the following steps of:

S210: determining whether the selected area is vacant; if yes, executing S300, and if not, executing S220; and

S220: determining whether a range of the first square constructed by the first range value contains a coordinate in the local coordinate set, and if yes, executing S300.

In a specific embodiment of the present disclosure, the updating the selected area of the to-be-labeled image based on the local coordinate set acquired comprises the following of:

highlighting or shadowing an area enclosed by coordinates in the local coordinate set.

In a specific embodiment of the present disclosure, the updating the local coordinate set based on the current edge coordinates acquired comprises the following steps of:

S510: determining whether the selected area is vacant; if yes, adding the current edge coordinates into the local coordinate set, and if not, executing S520; and

S520: deleting a coordinate in the current edge coordinates that is duplicated with a coordinate in the local coordinate set and then adding the remaining coordinates to the local coordinate set.

In a specific embodiment of the present disclosure, the generating the whole coordinate set comprises the following steps of:

S710: establishing a set A′, adding any coordinate point p₀ in the local coordinate set to the set A′, establishing other coordinate points except p₀ in the local coordinate set as a set A₂, and setting a first labeled coordinate point p as p₀ ;

S720: determining whether a number of elements in the set A₂ is zero; if not, executing S720a, and if yes, executing S720b;

S720a: calculating distances d between all coordinate points in the set A₂ and the first labeled coordinate point p, setting the first labeled coordinate point p as a coordinate point corresponding to the minimum distance d in the set A₂, adding the coordinate point corresponding to the minimum distance d in the set A₂ into the set A′ and deleting the coordinate point from the set A₂, and returning to S720;

S720b: sorting the coordinate points according to an order in which the coordinate points are added to the set A′;

S730: establishing the whole coordinate set, adding p into the whole coordinate set and deleting p₀ from the set A′, and setting a second labeled coordinate point p′ as p₀;

S740: determining whether a number of elements in the set A′ is 1; if not, executing S740a, and if yes, executing S740b;

S740a: determining whether the second labeled coordinate point p′ is collinear with the two coordinate points ranked in the first two places in the set A′ ; if yes, executing S740a1, and if not, executing S740a2;

S740a1: deleting the coordinate point in the first place in the set A′ from the set A′, and returning to S740;

S740a2: setting the second labeled coordinate point p′ as the coordinate point ranked in the first place in the set A′, adding the coordinate point ranked in the first place in the set A′ to the whole coordinate set and deleting the coordinate point from the set A′, and returning to S740; and

S740b: adding the coordinate points in the set A′ to the whole coordinate set and outputting the whole coordinate set.

In a second aspect, an embodiment of the present disclosure provides an electronic apparatus, comprising: a memory, a processor and a computer program stored on the memory and operatable on the processor, wherein the processor, when executing the program, performs the high-precision semi-automatic image data labeling method according to any one of the first aspect above.

The electronic apparatus according to the embodiment of the present disclosure has all the beneficial effects of the first aspect of the present disclosure because the electronic apparatus executes the high-precision semi-automatic image data labeling method according to any one of the first aspect above.

In a third aspect, an embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing a computer-executable instruction, wherein the computer-executable instruction is used for executing the high-precision semi-automatic image data labeling method according to any one of the first aspect above.

The non-transitory computer-readable storage medium according to the embodiment of the present disclosure has all the beneficial effects of the first aspect of the present disclosure because the non-transitory computer-readable storage medium executes the high-precision semi-automatic image data labeling method according to any one of the first aspect above.

Part of the additional aspects and advantages of the present disclosure will be given in part in the following description, and will become apparent in part from the following description, or will be learned through the practice of the present disclosure.

BRIEF DESCRIPTION OF DRAWINGS

The above and/or additional aspects and advantages of the present disclosure will be more apparent from the following description of the embodiments in conjunction with the accompanying drawings, wherein:

FIG. 1 is a schematic structural diagram of an electronic apparatus provided by a first embodiment of the present disclosure;

FIG. 2 is a flow chart of a high-precision semi-automatic image data labeling method provided by a second embodiment of the present disclosure;

FIG. 3 is an effect graph of constructing a first square according to a third embodiment of the present disclosure;

FIG. 4 is an effect graph of a semi-automatic image data labeling method provided by a fourth embodiment of the present disclosure;

FIG. 5 is an effect graph of using a grabcut algorithm for image segmentation in the prior art;

FIG. 6 is an effect graph of correcting an erroneously selected area in the second embodiment of the present disclosure; and

FIG. 7 is a schematic diagram showing effects on S920 in the second embodiment of the present disclosure.

REFERENCE NUMERALS

100 refers to electronic apparatus, 101 refers to processor, and 102 refers to memory

DETAILED DESCRIPTION

The embodiments of the present disclosure will be described in detail hereinafter. Examples of the embodiments are shown in the accompanying drawings. The same or similar reference numerals throughout the drawings denote the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only intended to explain the present disclosure, but should not be construed as limiting the present disclosure.

In the description of the present disclosure, it shall be understood that the orientation or position relation related to the orientation description, such as the orientation or position relation indicated by the upper, lower, front, rear, left, right, etc., is based on the orientation or position relation shown in the drawings, which is only used for convenience of description of the present disclosure and simplification of description instead of indicating or implying that the indicated device or element must have a specific orientation, and be constructed and operated in a specific orientation, and thus shall not be understood as a limitation to the present disclosure.

In the description of the present disclosure, the meaning of several refers to be one or more, and the meaning of multiple refers to be more than two. The meanings of greater than, less than, more than, etc., are understood as not including this number, while the meanings of above, below, within, etc., are understood as including this number. If there is a description to the first and second, it is only for the purpose of distinguishing technical features, and shall not be understood as indicating or implying relative importance, implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.

In the description of the present disclosure, unless otherwise explicitly defined, words such as setting, installing and connecting should be understood in a broad sense, and those skilled in the art can reasonably determine the specific meanings of the above words in the present disclosure, in combination with the specific contents of the technical solutions.

With the continuous breakthrough of computer technologies, artificial intelligence has become the theme of this era, and deep learning has become a huge breakthrough technology in recent years. However, the training of image segmentation networks based on deep learning needs a lot of image labeling data, such as intelligent garbage sorting system, which needs image labeling data to learn to identify garbage and garbage types. If this system is expected to identify waste paper, it is necessary to cut a large number of images containing waste paper (such as waste paper on the ground) to get waste paper images and background images, then label the waste paper images with data, and then submit the image labeling data to the system for learning.

Thus it can be seen that many systems that need intelligent identification, such as the intelligent garbage sorting system mentioned above, a surface defect detection system and automatic driving, all need a lot of image labeling data, which have to be segmented from images. There is an increasing demand for the image labeling data. To acquire the image labeling data, firstly, it is necessary to divide images containing targets into two parts comprising a target image and a background image, and then label the target image.

In order to meet the training requirements of the image segmentation networks based on deep learning for the image labeling data, a technology crowdsourcing platform emerges at the right moment. Some companies recruit tens of thousands of data labelers. However, due to some shortcomings of the existing data labeling methods, acquiring a large amount of image labeling data also needs to consume a lot of manpower, material resources and financial resources.

The existing data labeling method is to use open-source image segmentation data labeling tools (such as Labelme, Labelimg, or the like) to dot-plot edges of the target image (drawing the edges of the target object in the image by clicking the mouse, which may be clicked for hundreds of times in case of wanting to dot-plot the target objects with complex shapes, you may need to click the mouse hundreds of times), then separate the target image from the background, that is, segment the image to get the target image, and then label the target image acquired.

The present disclosure relates to an image segmentation technology with a traditional image segmentation algorithm grabcut as the main algorithm, and provides a pioneering semi-automatic data labeling method, which greatly reduces the times of dot-plotting or mouse clicking. Meanwhile, due to some chromatic aberration analysis mechanisms of the grabcut algorithm, the efficiency and precision of data labeling can be improved, and the training requirements of image segmentation networks based on deep learning for image data can be met.

Meanwhile, in some cases, the grabcut algorithm is not ideal for extracting target edges. The edges of the target image may also contain a part of the background image; wherein the important thing is that the grabcut algorithm lacks a function of correcting the target image obtained by image segmentation, that is, if an image segmentation effect in a data labeling process is not good, some background images may be included near the edge of the target image, and a method for correcting this situation is inefficient.

Based on this, the present disclosure provides a high-precision semi-automatic image data labeling method, an electronic apparatus and a non-transitory computer-readable storage medium. By displaying a to-be-labeled image on an electronic screen, current edge coordinates of outlines can be obtained by stages and areas for images with complex outline shapes of foreground images according to a coordinate point of an unselected area generated by a user clicking on the to-be-labeled image for many times and the first range value input by the user after generating the coordinate point of the unselected area in each time. Finally, the current edge coordinates acquired by stages and areas are merged into a local coordinate set, and after the user confirms that the foreground image is completely selected, the user sends an all-selected instruction. Meanwhile, when the foreground image contains a background image, a correction function is provided, and the correction function can be started by the presence of an instruction indicating that a erroneously selected area occurs to delete the erroneously selected area. After deleting the erroneously selected area, the correct foreground area deleted simultaneously in the process of deleting the erroneously selected area is re-selected by the grabcut algorithm. After receiving the all-selected instruction, a computer takes the current local coordinate set as a whole coordinate set, and receives classification information input by the user through the keyboard, such as football, and the like. Finally, the classification information and the whole coordinate set are saved as json files, which are convenient for future neural network training.

Many different embodiments or examples are provided below to realize different schemes of the present disclosure. It should be understood that the following description is only an exemplary description, not a specific limitation of the present disclosure.

Referring to FIG. 1 , which shows an electronic apparatus 100 provided by a first embodiment of the present disclosure, comprising a memory 102 and a processor 101. In FIG. 4 , one processor 101 and one memory 102 are taken as examples.

The processor and the memory may be connected by a bus or other ways, and connecting by bus is taken as an example in FIG. 1 .

As a non-transient computer-readable storage medium, the memory 102 may be used to store non-transient software programs and non-transient computer-executable programs. In addition, the memory 102 may comprise a high-speed random access memory, and may also comprise a non-transitory memory, such as at least one disk memory device, a flash memory device, or other non-transitory solid storage devices. In some embodiments, the memory 102 optionally comprises a memory 102 remotely disposed with respect to the processor, which may be connected to the electronic apparatus 100 through a network. Examples of the networks above comprise, but are not limited to, the Internet, intranet, local area networks, mobile communication networks, and combinations thereof.

FIG. 2 shows the electronic apparatus according to the first embodiment of the present disclosure. In this embodiment, the processor 101 in the electronic device 100 may be used to call a high-precision semi-automatic image data labeling method stored in the memory 102, and perform the following steps of:

S100: displaying a to-be-labeled image, the to-be-labeled image comprising a selected area and an unselected area;

S200: acquiring a coordinate point of the unselected area and a first range value;

S300: executing a grabcut algorithm based on the coordinate point of the unselected area and the first range value acquired, and obtaining a binarized image divided by the grabcut algorithm;

S400: executing an edge tracking algorithm on the binarized image to acquire current edge coordinates;

S500: updating a local coordinate set based on the current edge coordinates acquired;

S600: updating the selected area of the to-be-labeled image based on the local coordinate set acquired;

S700: determining whether an all-selected instruction is received; if yes, generating a whole coordinate set, and if not, returning to S200;

S800: determining whether an instruction indicating that an erroneously selected area occurs is received; if yes, executing S900, and if not, executing S1000;

S900: acquiring a coordinate point of the erroneously selected area and a second range, and displaying a second square on the to-be-labeled image by the coordinate point of the erroneously selected area and the second range;

S910: determining whether a coordinate in the whole coordinate set exists in the second square; if not, returning to S900, and if yes, executing S920;

S920: acquiring a first coordinate point and a second coordinate point in the whole coordinate set that are duplicated with coordinates on edges of the second square, deleting the coordinate point in the whole coordinate set that are duplicated within a range of the second square, and adding the first coordinate point, the second coordinate point and a third coordinate point into the whole coordinate set, wherein the third coordinate point is a diagonal point among four diagonal points of the second square with a shortest path to a sum of the first and second coordinate points along the edges of the second square, and returning to S700; and

S1000: acquiring category information and saving the category information and the whole coordinate set as json files.

In this embodiment, the to-be-labeled image may be displayed to a labeler through a PC screen or a tablet screen, and the labeled image comprises a foreground area and a background area. The labeler clicks on the foreground area with a mouse to generate a mouse event, so as to obtain the coordinate clicked by the mouse on the to-be-labeled image as the coordinate point of the unselected area. Then, the labeler inputs a numerical value from a keyboard as the first range value. The first range value comprises a distance value and an angle value input by the labeler from the keyboard. The distance value represents pixel points on the to-be-labeled image that meet the distance value with the coordinate point of the unselected area. Then, the angle value is rotated around the coordinate point of the unselected area to select a pixel point that meets the distance value as a diagonal point of the first square, thus determining a first square, and forming this first square equivalent to a frame-drawing interaction mode in the grabcut algorithm.

After acquiring the coordinate point of the unselected area and the first range value to generate the first square, the grabcut algorithm is executed to obtain the binarized image after division. After the image segmentation, the image may be divided into two parts comprising a target object (i.e., foreground) and a background. Then all the pixels of the target object are set to black and all the pixels of the background are set to white in a system, so all the pixels of the image are divided into two numerical values, black and white. This is the binarized image. These data are stored in the system, and then the edge tracking algorithm is applied to the binarized image to obtain the current edge coordinates, which are outline pixel coordinates of the current binarized image.

The current edge coordinates are saved as the local coordinate set, and an area enclosed by the coordinates in the local coordinate set are highlighted or shadowed. This part of area that is highlighted or shadowed is the selected area. In the case that the foreground image is complex, the selected area may only be a part of the foreground when the grabcut algorithm is executed for the first time. Therefore, if the labeler does not send an all-selected instruction, the position of the mouse may be re-captured to form a new coordinate point of the unselected area and wait for the user to input a new first range value, and then execute the grabcut algorithm on the unselected area to obtain new current edge coordinates. After acquiring the new current edge coordinates, the new edge coordinates are compared with the coordinates in the local coordinate set obtained in the previous round, delete the same current edge coordinates, add the remaining current edge coordinates into the local coordinate set, and then highlight or shadow the area enclosed by the coordinates in the local coordinate set of this round. The selected area in this round may increase. According to the judgment of the labeler, if it is considered that the current selected area has not met the precision requirement, S200 may continue to be repeated, until the labeler thinks that the coincidence degree between the selected area and the foreground meets the requirements, and the all-selected instruction may be sent to complete the labeling of one to-be-labeled image. With the method of this embodiment, multiple small-scale image segmentation algorithms can be realized, which can improve the precision of the semi-automatic labeling for images with complex outline shapes.

FIG. 6 is an effect graph of correcting the erroneously selected area according to the second embodiment of the present disclosure. When a background image exists in the selected area, correction may be deleted through steps S800 to S920.

FIG. 7 is an effect graph of S920 according to the second embodiment of the present disclosure. When it is confirmed that the foreground image is completely selected, the selected area may contain the background image. In this case, if the labeler wants to correct the selected area, an instruction indicating that an erroneously selected area exists may be sent through the keyboard. In this case, S900 may be executed, comprising: acquiring a coordinate point of a position in the erroneously selected area of the selected area clicked by the mouse of the user as a coordinate point of the erroneously selected area, and receiving a value input by the keyboard as a second range value, and generating the second square through the second range value which comprises a distance value and an angle value input by the labeler from the keyboard, this distance value representing pixel points on the to-be-labeled image that meet the distance value with the coordinate point of the erroneously selected area, and then turning the angle value around the coordinate point of the erroneously selected area to select the pixel point that meets the distance value as the diagonal point of the second square. It is required that the range of the second square should comprise the coordinate points in the whole coordinate set, that is, an outline of the selected area should intersect with an edge of the second square. The coordinate points in the whole coordinate set within the range of the second square are deleted, and a first coordinate point, a third coordinate point and a second coordinate point on the edge of the second square are connected in turn to form a new outline of the selected area.

FIG. 3 is an effect graph of constructing a first square according to a third embodiment of the present disclosure. The third embodiment of the present disclosure provides a high-precision semi-automatic image data labeling method, wherein the first range value is used for constructing the first square, and acquiring the first range value comprises the following steps of:

S210: determining whether the selected area is vacant; if yes, executing S300, and if not, executing S220; and

S220: determining whether a range of the first square constructed by the first range value contains a coordinate in the local coordinate set, and if yes, executing S300.

In this embodiment, when the coordinate point of the unselected area is acquired for the first time, the selected area is vacant, and the judgment is based on whether the local coordinate set is vacant. If a coordinate exists in the local coordinate set, it is judged that the selected area is not vacant.

When the coordinate point of the unselected area is obtained for the second time, the selected area is not vacant. As shown in 3-a, 3-b and 3-c of FIG. 3 , after clicking the unselected area with the mouse for the second time and acquiring the first range value, THE grabcut algorithm may be executed to acquire the binarized image of the range of the first square, then the current edge coordinates are acquired, and then the current edge coordinates are merged with the local coordinate set in the first time. This process is called updating the local coordinate set.

As shown in 3-d of FIG. 3 , in this embodiment, it is stipulated that if the range of the first square formed by the coordinate point of the unselected area and the first range value for the second time does not comprise any coordinates in the local coordinate set for the first time, the square cannot be selected, and the labeler needs to re-enter the first range value.

A fourth embodiment of the present disclosure provides a high-precision semi-automatic image data labeling method, wherein the updating the selected area of the to-be-labeled image based on the local coordinate set acquired comprises the following of:

highlighting or shadowing an area enclosed by coordinates in the local coordinate set.

In this embodiment, the area enclosed by the coordinates in the local coordinate set is highlighted or shadowed to facilitate the labeler to confirm the selected area and the unselected area. It is convenient for the user to identify the currently selected area by increasing the brightness and adjusting colors of the pixels in the area enclosed by the coordinates in the local coordinate set.

FIG. 4 is an effect graph of a semi-automatic image data labeling method provided by a fourth embodiment of the present disclosure. A shadow algorithm is used for all the pixels in the area enclosed by the coordinates in the local coordinate set, so that the area is shadowed to output an image with a darkened local area, which is convenient for the user to identify a selected local area in the target object.

A fifth embodiment of the present disclosure provides a high-precision semi-automatic image data labeling method, wherein the updating the local coordinate set based on the current edge coordinates acquired comprises the following steps of:

S510: determining whether the selected area is vacant; if yes, adding the current edge coordinates into the local coordinate set, and if not, executing S520; and

S520: deleting a coordinate in the current edge coordinates that is duplicated with a coordinate in the local coordinate set and then adding the remaining coordinates to the local coordinate set.

In this embodiment, the local coordinate set is updated for once in each round, and the area enclosed by the coordinates in the local coordinate set is highlighted or shadowed, and fed back to the labeler in real time to facilitate the operation of the labeler.

A sixth embodiment of the present disclosure provides a high-precision semi-automatic image data labeling method, wherein the generating the whole coordinate set comprises the following steps of:

S710: establishing a set A′, adding any coordinate point p₀ in the local coordinate set to the set A′, establishing other coordinate points except p₀ in the local coordinate set as a set A′, and setting a first labeled coordinate point p as p₀ ;

S720: determining whether a number of elements in the set A₂ is zero; if not, executing S720a, and if yes, executing S720b;

S720a: calculating distances d between all coordinate points in the set A₂ and the first labeled coordinate point p, setting the first labeled coordinate point p as a coordinate point corresponding to the minimum distance d in the set A₂ , adding the coordinate point corresponding to the minimum distance d in the set A₂ into the set A′ and deleting the coordinate point from the set A₂, and returning to S720;

S720b: sorting the coordinate points according to an order in which the coordinate points are added to the set A′;

S730: establishing the whole coordinate set, adding p₀ into the whole coordinate set and deleting p₀ from the set A′, and setting a second labeled coordinate point p′ as p₀ ;

S740: determining whether a number of elements in the set A′ is 1; if not, executing S740a, and if yes, executing S740b;

S740a: determining whether the second labeled coordinate point p′ is collinear with the two coordinate points ranked in the first two places in the set A′; if yes, executing S740a1, and if not, executing S740a2;

S740a1: deleting the coordinate point in the first place in the set A′ from the set A′, and returning to S740;

S740a2: setting the second labeled coordinate point p as the coordinate point ranked in the first place in the set A′, adding the coordinate point ranked in the first place in the set A′ to the whole coordinate set and deleting the coordinate point from the set A′, and returning to S740; and

S740b: adding the coordinate points in the set A′ to the whole coordinate set and outputting the whole coordinate set.

In manual labeling, for the case where part of the outline of the foreground area is straight, for example, for the case where the real target area is a square, the labeler usually only clicks four vertices of the square with the mouse and pulls a straight line between two adjacent vertices. Therefore, only four pixel points are needed to represent coordinates of the square, which greatly reduces the data volume. However, when using a semi-automatic labeling method, because the grabcut algorithm is used to realize automatic segmentation, and edge tracking algorithm is executed to acquire edge pixel coordinates of the binarized image as the current edge coordinates, the current edge coordinates are composed of a series of neighboring pixel points, while the whole coordinate set is composed of the current edge coordinates obtained by many times, resulting in a large data volume of the whole coordinate set.

This embodiment provides an algorithm to simplify the coordinates in the whole coordinate set obtained. The algorithm comprises two parts. The first part is from S710 to S720. These steps sort the coordinate points in the whole coordinate set according to an order in which the coordinate points are added to the set A′. If the coordinate points in the whole coordinate set are passed through in turn according to the order in which the coordinate points are added to the set A′, these coordinate points just enclose the outline of the selected area. Therefore, the second part of S730 to S740 is to sequentially check whether the three adjacent points on the outline of the selected area are collinear according to the order of adding these point to the set A′, and if the three adjacent points are collinear, the middle point is removed, and only the first and third points are reserved, thus achieving the effect of manual labeling and reducing the data volume generated by semi-automatic labeling.

A seventh embodiment of the present disclosure provides a non-transitory computer-readable storage medium storing a computer-executable instruction, wherein the computer-executable instruction is used for executing the high-precision semi-automatic image data labeling method according to any one of the second to sixth embodiments above.

The embodiments of the present disclosure are described in detail with reference to the drawings above, but the present disclosure is not limited to the above embodiments, and various changes may also be made within the knowledge scope of those of ordinary skills in the art without departing from the purpose of the present disclosure. 

What is claimed is:
 1. A high-precision semi-automatic image data labeling method, comprising: S100: displaying a to-be-labeled image, the to-be-labeled image comprising a selected area and an unselected area; S200: acquiring a coordinate point of the unselected area and a first range value; S300: executing a grabcut algorithm based on the coordinate point of the unselected area and the first range value acquired, and obtaining a binarized image divided by the grabcut algorithm; S400: executing an edge tracking algorithm on the binarized image to acquire current edge coordinates; S500: updating a local coordinate set based on the current edge coordinates acquired; S600: updating the selected area of the to-be-labeled image based on the local coordinate set acquired; S700: determining whether an all-selected instruction is received; in response to being yes, generating a whole coordinate set, and in response to being not, returning to S200; S800: determining whether an instruction indicating that an erroneously selected area occurs is received; in response to being yes, executing S900, and in response to being not, executing S1000; S900: acquiring a coordinate point of the erroneously selected area and a second range, and displaying a second square on the to-be-labeled image by the coordinate point of the erroneously selected area and the second range; S910: determining whether a coordinate in the whole coordinate set exists in the second square; in response to being not, returning to S900, and in response to being yes, executing S920; S920: acquiring a first coordinate point and a second coordinate point in the whole coordinate set that are duplicated with coordinates on edges of the second square, deleting the coordinate point in the whole coordinate set that are duplicated within a range of the second square, and adding the first coordinate point, the second coordinate point and a third coordinate point into the whole coordinate set, wherein the third coordinate point is a diagonal point among four diagonal points of the second square with a shortest path to a sum of the first and second coordinate points along the edges of the second square, and returning to S700; and S1000: acquiring category information and saving the category information and the whole coordinate set as json files.
 2. The high-precision semi-automatic image data labeling method of claim 1, wherein the first range value is used for constructing a first square, and acquiring the first range value comprises the following steps of: S210: determining whether the selected area is vacant; in response to being yes, executing S300, and in response to being not, executing S220; and S220: determining whether a range of the first square constructed by the first range value contains a coordinate in the local coordinate set, and in response to being yes, executing S300.
 3. The high-precision semi-automatic image data labeling method of claim 1, wherein the updating the selected area of the to-be-labeled image based on the local coordinate set acquired comprises the following of: highlighting or shadowing an area enclosed by coordinates in the local coordinate set.
 4. The high-precision semi-automatic image data labeling method of claim 1, wherein the updating the local coordinate set based on the current edge coordinates acquired comprises the following steps of: S510: determining whether the selected area is vacant; in response to being yes, adding the current edge coordinates into the local coordinate set, and in response to being not, executing S520; and S520: deleting a coordinate in the current edge coordinates that is duplicated with a coordinate in the local coordinate set and then adding the remaining coordinates to the local coordinate set.
 5. The high-precision semi-automatic image data labeling method of claim 1, wherein the generating the whole coordinate set comprises the following steps of: S710: establishing a set A′, adding any coordinate point p₀ in the local coordinate set to the set A′, establishing other coordinate points except p₀ in the local coordinate set as a set A₂, and setting a first labeled coordinate point p as p₀; S720: determining whether a number of elements in the set 4 is zero; in response to being not, executing S720a, and in response to being yes, executing S720b; S720a: calculating distances d between all coordinate points in the set A₂ and the first labeled coordinate point p, setting the first labeled coordinate point p as a coordinate point corresponding to the minimum distance d in the set A₂, adding the coordinate point corresponding to the minimum distance d in the set 4 into the set A′ and deleting the coordinate point from the set A₂, and returning to S720; S720b: sorting the coordinate points according to an order in which the coordinate points are added to the set A′; S730:establishing the whole coordinate set, adding p₀ into the whole coordinate set and deleting p₀ from the set A′, and setting a second labeled coordinate point p′ as p₀; S740: determining whether a number of elements in the set A′ is 1; in response to being not, executing S740a, and in response to being yes, executing S740b; S740a: determining whether the second labeled coordinate point p′ is collinear with the two coordinate points ranked in the first two places in the set A′; in response to being yes, executing S740a1, and in response to being not, executing S740a2; S740a1: deleting the coordinate point in the first place in the set A′ from the set A′, and returning to S740; S740a2: setting the second labeled coordinate point p′ as the coordinate point ranked in the first place in the set A′, adding the coordinate point ranked in the first place in the set A′ to the whole coordinate set and deleting the coordinate point from the set A′, and returning to S740; and S740b: adding the coordinate points in the set A′ to the whole coordinate set and outputting the whole coordinate set.
 6. An electronic apparatus, comprising a memory, a processor and a computer program stored in the memory and executable by the processor, wherein the computer program, when executed by the processor, causes the processor to perform the steps of a high-precision semi-automatic image data labeling method, comprising: S100: displaying a to-be-labeled image, the to-be-labeled image comprising a selected area and an unselected area; S200: acquiring a coordinate point of the unselected area and a first range value; S300: executing a grabcut algorithm based on the coordinate point of the unselected area and the first range value acquired, and obtaining a binarized image divided by the grabcut algorithm; S400: executing an edge tracking algorithm on the binarized image to acquire current edge coordinates; S500: updating a local coordinate set based on the current edge coordinates acquired; S600: updating the selected area of the to-be-labeled image based on the local coordinate set acquired; S700: determining whether an all-selected instruction is received; in response to being yes, generating a whole coordinate set, and in response to being not, returning to S200; S800: determining whether an instruction indicating that an erroneously selected area occurs is received; in response to being yes, executing S900, and in response to being not, executing S1000; S900: acquiring a coordinate point of the erroneously selected area and a second range, and displaying a second square on the to-be-labeled image by the coordinate point of the erroneously selected area and the second range; S910: determining whether a coordinate in the whole coordinate set exists in the second square; in response to being not, returning to S900, and in response to being yes, executing S920; S920: acquiring a first coordinate point and a second coordinate point in the whole coordinate set that are duplicated with coordinates on edges of the second square, deleting the coordinate point in the whole coordinate set that are duplicated within a range of the second square, and adding the first coordinate point, the second coordinate point and a third coordinate point into the whole coordinate set, wherein the third coordinate point is a diagonal point among four diagonal points of the second square with a shortest path to a sum of the first and second coordinate points along the edges of the second square, and returning to S700; and S1000: acquiring category information and saving the category information and the whole coordinate set as json files.
 7. A non-transitory computer-readable storage medium, storing computer-executable instructions, which, when executed by a processor, causes the processor to perform the steps of a high-precision semi-automatic image data labeling method, comprising: S100: displaying a to-be-labeled image, the to-be-labeled image comprising a selected area and an unselected area; S200: acquiring a coordinate point of the unselected area and a first range value: S300: executing a grabcut algorithm based on the coordinate point of the unselected area and the first range value acquired, and obtaining a binarized image divided by the grabcut algorithm; S400: executing an edge tracking algorithm on the binarized image to acquire current edge coordinates; S500: updating a local coordinate set based on the current edge coordinates acquired; S600: updating the selected area of the to-be-labeled image based on the local coordinate set acquired; S700: determining whether an all-selected instruction is received; in response to being yes, generating a whole coordinate set, and in response to being not, returning to S200; S800: determining whether an instruction indicating that an erroneously selected area occurs is received; in response to being yes, executing S900, and in response to being not, executing S1000; S900: acquiring a coordinate point of the erroneously selected area and a second range, and displaying a second square on the to-be-labeled image by the coordinate point of the erroneously selected area and the second range; S910: determining whether a coordinate in the whole coordinate set exists in the second square; in response to being not, returning to S900, and in response to being yes, executing S920; S920: acquiring a first coordinate point and a second coordinate point in the whole coordinate set that are duplicated with coordinates on edges of the second square, deleting the coordinate point in the whole coordinate set that are duplicated within a range of the second square, and adding the first coordinate point, the second coordinate point and a third coordinate point into the whole coordinate set, wherein the third coordinate point is a diagonal point among four diagonal points of the second square with a shortest path to a sum of the first and second coordinate points along the edges of the second square, and returning to S700; and S1000: acquiring category information and saving the category information and the whole coordinate set as json files. 